<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>游戏登录页面 - 星空动画背景</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            overflow: hidden;
            background: #000;
            color: #fff;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #starCanvas {
            position: fixed;
            top: 0;
            left: 0;
            z-index: -1;
        }

        .login-container {
            background: rgba(0, 0, 0, 0.7);
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
            width: 350px;
            max-width: 90%;
            backdrop-filter: blur(5px);
            border: 1px solid rgba(0, 255, 255, 0.2);
            animation: glow 2s infinite alternate;
        }

        @keyframes glow {
            from {
                box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
            }
            to {
                box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
            }
        }

        h1 {
            text-align: center;
            margin-bottom: 30px;
            color: #0ff;
            font-size: 28px;
            text-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
        }

        .input-group {
            margin-bottom: 20px;
            position: relative;
        }

        .input-group input {
            width: 100%;
            padding: 12px 15px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(0, 255, 255, 0.3);
            border-radius: 5px;
            color: #fff;
            font-size: 16px;
            transition: all 0.3s;
        }

        .input-group input:focus {
            outline: none;
            border-color: #0ff;
            box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
            background: rgba(255, 255, 255, 0.15);
        }

        .input-group label {
            position: absolute;
            left: 15px;
            top: 12px;
            color: rgba(255, 255, 255, 0.7);
            pointer-events: none;
            transition: all 0.3s;
        }

        .input-group input:focus + label,
        .input-group input:valid + label {
            top: -10px;
            left: 10px;
            font-size: 12px;
            background: rgba(0, 0, 0, 0.8);
            padding: 0 5px;
            color: #0ff;
        }

        button {
            width: 100%;
            padding: 12px;
            background: linear-gradient(45deg, #0066ff, #00ccff);
            border: none;
            border-radius: 5px;
            color: white;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            margin-top: 10px;
        }

        button:hover {
            background: linear-gradient(45deg, #00ccff, #0066ff);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 204, 255, 0.4);
        }
        .dl{
            width: 100%;
            padding: 12px;
            background: linear-gradient(45deg, #0066ff, #00ccff);
            border: none;
            border-radius: 5px;
            color: white;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            margin-top: 10px;
        }
        .dl:hover{
            background: linear-gradient(45deg, #00ccff, #0066ff);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 204, 255, 0.4);
        }

        .links {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
            font-size: 14px;
        }

        .links a {
            color: rgba(0, 255, 255, 0.7);
            text-decoration: none;
            transition: color 0.3s;
        }

        .links a:hover {
            color: #0ff;
            text-decoration: underline;
        }
    </style>
</head>
<body>
<canvas id="starCanvas"></canvas>

<div class="login-container">
    <div>
        <h1>登录</h1>
        <form id="form">
            <div class="input-group">
                <input type="text" name="username" id="username" required>
                <label for="username">用户名</label>
            </div>
            <div class="input-group">
                <input type="password" id="password" name="password" required>
                <label for="password">密码</label>
            </div>
<!--            <button type="submit" id="submit">登录</button>-->
            <input class="dl" type="button" value="登录" id="submit"/>
<!--            <div class="links">-->
<!--                <a href="#">注册账号</a>-->
<!--                <a href="#">忘记密码?</a>-->
<!--            </div>-->
        </form>
    </div>

</div>

<script>
    // 星空背景动画
    const canvas = document.getElementById('starCanvas');
    const ctx = canvas.getContext('2d');

    // 设置canvas大小为窗口大小
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;

    // 星星数组
    const stars = [];
    const starCount = 200;

    // 星星类
    class Star {
        constructor() {
            this.x = Math.random() * canvas.width;
            this.y = Math.random() * canvas.height;
            this.size = Math.random() * 3;
            this.speed = Math.random() * 0.2 + 0.05;
            this.opacity = Math.random();
            this.waveSpeed = Math.random() * 0.02 + 0.01;
            this.waveSize = Math.random() * 0.5 + 0.5;
        }

        update() {
            this.y += this.speed;
            if (this.y > canvas.height) {
                this.y = 0;
                this.x = Math.random() * canvas.width;
            }

            // 添加波动效果
            this.opacity = this.waveSize + Math.sin(Date.now() * this.waveSpeed) * this.waveSize;
        }

        draw() {
            ctx.beginPath();
            ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
            ctx.fillStyle = `rgba(255, 255, 255, ${this.opacity})`;
            ctx.fill();
        }
    }

    // 初始化星星
    for (let i = 0; i < starCount; i++) {
        stars.push(new Star());
    }

    // 动画循环
    function animate() {
        // 清除画布，使用半透明黑色实现拖尾效果
        ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
        ctx.fillRect(0, 0, canvas.width, canvas.height);

        // 更新和绘制所有星星
        stars.forEach(star => {
            star.update();
            star.draw();
        });

        requestAnimationFrame(animate);
    }

    // 开始动画
    animate();

    // 窗口大小调整时重置canvas大小
    window.addEventListener('resize', () => {
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
    });

    // 添加鼠标移动交互效果
    let mouseX = 0;
    let mouseY = 0;

    window.addEventListener('mousemove', (e) => {
        mouseX = e.clientX;
        mouseY = e.clientY;

        // 创建鼠标经过时的星星轨迹
        if (Math.random() > 0.7) {
            const trailStar = new Star();
            trailStar.x = mouseX + (Math.random() - 0.5) * 50;
            trailStar.y = mouseY + (Math.random() - 0.5) * 50;
            trailStar.size = Math.random() * 2 + 1;
            trailStar.speed = Math.random() * 0.5 + 0.2;
            stars.push(trailStar);

            // 限制星星数量
            if (stars.length > starCount * 1.5) {
                stars.splice(0, 20);
            }
        }
    });
</script>
</body>
</html>